package com.app.micaihu.view.army.adapter.messageprovider

import android.widget.ImageView
import com.app.micaihu.R
import com.app.micaihu.view.army.adapter.ArmyMessageListAdapter
import com.app.micaihu.view.bean.ArmyMessage
import com.app.micaihu.view.utils.loadCircleImage
import com.chad.library.adapter.base.provider.BaseItemProvider
import com.chad.library.adapter.base.viewholder.BaseViewHolder

/**
 * 军团消息  邀请消息
 */
class MessageInviteItemProvider : BaseItemProvider<ArmyMessage>() {

    override val itemViewType: Int
        get() = ArmyMessageListAdapter.itemInvite

    override val layoutId: Int
        get() = R.layout.army_message_list_invite_item

    //列表 状态0等待通过，1已通过，2拒绝，3退出
    override fun convert(helper: BaseViewHolder, item: ArmyMessage) {
        helper.getView<ImageView>(R.id.ivSysIcon).loadCircleImage(R.mipmap.icon)
        helper.setText(R.id.tvTime, item.datetime)
        helper.setText(R.id.tvGid, "番号 " + item.gid)
        helper.setText(R.id.tvDesc, item.msg)
        item.armyInfo?.let {
            helper.setText(R.id.tvNickName, it.title)
            helper.setText(R.id.tvWarZone, it.war_zone)
            helper.setText(R.id.tvLevel, it.level)
        }

        when (item.status) {
            0 -> {
                helper.setVisible(R.id.tvInviteReject, true)
                helper.setVisible(R.id.tvInviteAgree, true)
                helper.setGone(R.id.tvState, true)
            }
            1 -> {
                helper.setGone(R.id.tvInviteReject, true)
                helper.setGone(R.id.tvInviteAgree, true)
                helper.setVisible(R.id.tvState, true)
                helper.setText(R.id.tvState, "已通过")
            }
            2 -> {
                helper.setGone(R.id.tvInviteReject, true)
                helper.setGone(R.id.tvInviteAgree, true)
                helper.setVisible(R.id.tvState, true)
                helper.setText(R.id.tvState, "已拒绝")
            }
        }
    }

}